import Promise from '../plugins/es6-promise.js'
const contentType = {
  "content-type": "application/x-www-form-urlencoded"
}
export default (options) => {
  return new Promise((resolve, reject) => {
    const url = options.url
    const header = options.method == 'POST' ? contentType : {}
    wx.request({
      url: url,
      method: options.method,
      data: options.data,
      header: header,
      success(res) {
        resolve(res)
      },
      fail (fail) {
        wx.showToast({
          title: '数据请求失败！',
          icon: 'none',
          duration: 2000
        })
      }
    })
  })
}